﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="CheckInDetails.ascx.cs"
    Inherits="UserControl_CheckInDetails" %>
<%@ Register Src="~/UserControl/HotelRoom.ascx" TagName="Room" TagPrefix="uc" %>
<gr:Container ID="Container1" runat="server" HeaderText="Thông tin đặt phòng">
    <div class="ContainerInput">
        <table class="TableFourColumns" cellpadding="0" cellspacing="0">
            <tr>
                <td class="label">
                    <gr:Literal runat="server" ID="uxCheckInDateLabel" Text="Ngày vào" />
                    <span class="required">(*)</span>
                </td>
                <td class="input">
                    <gr:GuruDateTimePicker Width="250px" runat="server" ID="uxCheckInDate">
                        <ClientEvents OnDateSelected="doChangeCheckInTime" />
                    </gr:GuruDateTimePicker>
                </td>
                <td class="label">
                    <gr:Literal runat="server" ID="uxPrepaidLabel" Text="Tiền tạm ứng" />
                </td>
                <td class="input">
                      <gr:GuruNumericTextBox ID="uxPrepaid" Width="160px" MaxLength="12" Type="Number" runat="server">
                        <NumberFormat  DecimalDigits="0"/>
                    </gr:GuruNumericTextBox>
                </td>
            </tr>
            <tr>
                <td class="label">
                    <gr:Literal runat="server" ID="uxCheckOutDateLabel" Text="Ngày ra" />
                </td>
                <td class="input">
                    <gr:GuruDateTimePicker Width="250px" ClientEvents-OnDateSelected="doChangeCheckInTime" runat="server" ID="uxCheckOutDate">
                    </gr:GuruDateTimePicker>
                </td>
                <td class="label">
                    <gr:Literal runat="server" ID="uxPromotionLabel" Text="Khuyến mãi" />
                </td>
                <td class="input">
                    <gr:GuruNumericTextBox ID="uxPromotion" Width="160px" MaxLength="12" Type="Number" runat="server">
                        <NumberFormat DecimalDigits="0"/>
                    </gr:GuruNumericTextBox>
                </td>
            </tr>
            
            <tr>
                <td class="label">
                    <gr:Literal runat="server" ID="uxNumberOfCustLabel" Text="Hình thức lưu trú" />
                </td>
                <td class="input">        
                    <gr:GuruComboBox runat="server" Enabled="true" ID="uxCheckInType" Width="187px" DataValueField="FixedID" OnClientSelectedIndexChanged="doChangeCheckInTime">
                    </gr:GuruComboBox>
                </td>
                 <td class="label" valign="top">
                    <gr:Literal runat="server" ID="uxNotesLabel" Text="Ghi chú" />
                </td>
                <td class="input" rowspan="2" valign="top">
                    <gr:TextBox ID="uxNotes" TextMode="MultiLine" Height="50px" Rows="2" runat="server"
                        Width="100%">
                    </gr:TextBox>
                </td>
            </tr>
            
            <tr>
                <td class="label">
                    <gr:Literal runat="server" ID="uxStayTimeLabel" Text="Thời gian lưu trú" />
                </td>
                <td class="input" valign="top">
                   <gr:TextBox ID="uxStayTime" Width="177px" style=" text-align: right;" runat="server" Enabled="false" ReadOnly="true"></gr:TextBox>                
                </td>
               
            </tr>
            
        </table>
    </div>
    <div id="uxRoomPanel" runat="server" class="containerHasBG" style="padding:0px 5px 5px 5px">
        <gr:ContainerButton ID="ContainerButton1" runat="server">            
            <gr:LinkButton ID="uxSelectRooms" CssClass="button buttonGray" runat="server" Text="Chọn phòng" OnClientClick="return parent.ShowPopupModalChild(2, 'SelectRoomsModal.aspx');"></gr:LinkButton>
            <gr:LinkButton ID="uxClear" OnClick="uxClear_Click" CssClass="button buttonGray" runat="server" Text="Xóa"></gr:LinkButton>   
        </gr:ContainerButton>
        <div class="containerInner" style="min-height: 65px; padding-top:5px;">
            <gr:DataList ID="uxRoomList" runat="server" OnItemDataBound="uxRoomList_ItemDataBound"  RepeatDirection="Horizontal" RepeatLayout="Flow" >
                <ItemTemplate>
                    <uc:Room ID="uxRoom" runat="server" SelectionMode="None" />
                </ItemTemplate>
            </gr:DataList>   
            <div style="clear:both;"></div>        
        </div>
         
    </div>
    <div style="display:none;">
        <gr:Button runat="server" ID="uxReloadRoom" OnClick="uxReloadRoom_Click" />  
        <gr:HiddenField runat="server" ID="uxSelectedRoom" />     
    </div>
    <gr:Validator ID="Validator1" runat="server" ValidationFunction="validateRooms" MessageType="AlertBox">
        <Items>
            <gr:BasicValidationItem ControlToValidateID="uxSelectedRoom" Rule="Required"  ResMessage="Resources.MessageManager.RequireSelectOneRoom"/>            
        </Items>
    </gr:Validator>
   <gr:GuruAjaxManagerProxy runat="server" ID="GuruAjaxManagerProxy1">
        <AjaxSettings>
            <gr:GuruAjaxSetting AjaxControlID="uxReloadRoom">
               <UpdatedControls>
                    <gr:GuruUpdatedControl ControlID="uxRoomList" />
               </UpdatedControls>
            </gr:GuruAjaxSetting>
           <gr:GuruAjaxSetting AjaxControlID="uxClear">
               <UpdatedControls>
                    <gr:GuruUpdatedControl ControlID="uxRoomList" />
                    <gr:GuruUpdatedControl ControlID="uxSelectedRoom" />
               </UpdatedControls>
            </gr:GuruAjaxSetting>
        </AjaxSettings>
    </gr:GuruAjaxManagerProxy>
    <gr:GuruCodeBlock ID="GuruCodeBlock1" runat="server">
        <script type="text/javascript" src="<%= ResolveUrl("~/")%>Assets/Js/Hotel.js"></script>
        <script type="text/javascript">
            $(document).ready(function(){
                doChangeCheckInTime('','');
            });
            function doChangeCheckInTime(sender, args){
              var checkInDate = $find("<%=uxCheckInDate.ClientID %>").get_selectedDate();
              var checkOutDate = $find("<%=uxCheckOutDate.ClientID %>").get_selectedDate();
              var checkInType = $find("<%=uxCheckInType.ClientID %>").get_selectedItem();
              var checkInTypeValue = checkInType.get_value();              
              var stayTime = 0;
              if(checkInTypeValue==("1")){
                stayTime = (checkOutDate - checkInDate)/(1000 * 60 * 60);
              }
              if(checkInTypeValue=="2"){
                stayTime = (checkOutDate - checkInDate)/(1000 * 60 * 60 * 24);
              }
              if(stayTime <= 0){
                stayTime = 0;
              }
              else {                
                var r = Math.round(stayTime);
                if(r < stayTime) r += 1;
                stayTime = r;
                
              }
              $("#<%=uxStayTime.ClientID %>").val(stayTime);
             
            }
            parent.OnSelectedChanged = function(args)
            {
               $("#<%=uxSelectedRoom.ClientID %>").val(args);
               document.getElementById("<%=uxReloadRoom.ClientID %>").click();
            }
        </script>
    </gr:GuruCodeBlock>
</gr:Container>

